import urllib
import urllib2

page = 1
url = 'http://www.qiushibaike.com/hot/page/' + str(page)
user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
headers = { 'User-Agent' : user_agent }
try:
    request = urllib2.Request(url,headers = headers)
    response = urllib2.urlopen(request)
    content = response.read()
#print content
except urllib2.URLError, e:
    if hasattr(e,"code"):
        print e.code
    if hasattr(e,"reason"):
        print e.reason

from bs4 import BeautifulSoup
qb = {'name':[], 'age':[], 'article':[], 'votes':[], 'comments':[]}

soup = BeautifulSoup(content,'lxml')

#print soup.find_all("div", class_="article block untagged mb15")
for i in soup.find_all("div", class_="article block untagged mb15"):
    item = BeautifulSoup(str(i),'lxml')

qb['name'].append(item.img['alt'])
qb['age'].append(item.div.div.div.string)
qb['article'].append(item.find('div', class_='content').get_text())
qb['votes'].append(item.find('span', class_='stats-vote').find('i', class_='number').string)
qb['comments'].append(item.find('span', class_='stats-comments').find('i', class_='number').string)